
<div class="itemtitle">
	<h3>分类列表</h3>
</div>
<table class="tb tb2 ">
<tbody>
	<tr class="header"><th>一级分类</th><th>二级分类</th><th>三级分类</th><th>四级分类</th><th></th></tr>
	{{foreach $cateList as $cid=>$cate}}
	<tr class="hover">
		<td class="td24">{{if 1 == $cate.level}}{{$cate.name}}{{/if}}</td>
		<td class="td24">{{if 2 == $cate.level}}{{$cate.name}}{{/if}}</td>
		<td class="td24">{{if 3 == $cate.level}}{{$cate.name}}{{/if}}</td>
		<td class="td24">{{if 4 == $cate.level}}{{$cate.name}}{{/if}}</td>
		<td class="td23">
			<a href="cate_edit.php?cid={{$cid}}">编辑</a>&nbsp;
			<a href="#" class="_j_cate_delete" data-cid="{{$cid}}">删除</a>
		</td>
	</tr>
	{{/foreach}}
</tbody>
</table>

<script>
K.App('apps/admin/ACategory.js', ['jQuery']).define(function() {

    var $ = this.require('jQuery');

    return {

		'container' : '#cpcontainer',

        'events' : {
            'click ._j_cate_delete' : 'onCateDelete'
        },

        'main' : function() {
        },

        'onCateDelete' : function(evt) {
        	evt.preventDefault();
        	
        	var ctx = this.getContainer(),
        		target = $(evt.currentTarget),
        		cid = target.data('cid');
        	
			// 确认
			if (!confirm('您确定删除么？')) {
				return;
			}

           	// 提交结果
           	$.ajax({
           		'url' : '/admin/ajax/cate_delete.php',
           		'data' : {'cid':cid},
           		'type' : 'POST',
           		'success' : function(data){
                    	data = $.parseJSON(data);
                    	if (data.error) {
                    		alert(data.error.errmsg);
                    	} else {
                    		window.location.reload();
                    	}
           		}
           	});
        }
    }
});
</script>
			